package org.hhchat.leetcode.array;

import java.util.Arrays;

/**
 * Created this one by HMH on 2017/10/2.
 */
public class code506_easy {

    static class Solution {
        public String[] findRelativeRanks(int[] nums) {
            int[][] data = new int[nums.length][2];
            for (int i = 0; i < nums.length; i++) {
                data[i][0] = nums[i];
                data[i][1] = i;
            }
            Arrays.sort(data,(a,b)->(b[0]-a[0]));
            String[] result = new String[nums.length];
            for(int i=0;i<nums.length;i++) {
                if (i == 0) {
                    result[data[0][1]] = "Gold Medal";
                }
                else if (i == 1) {
                    result[data[1][1]] = "Silver Medal";
                }
                else if (i == 2) {
                    result[data[2][1]] = "Bronze Medal";
                }
                else {
                    result[data[i][1]] = i+1 + "";
                }

            }
            return result;
        }
    }

    public static void main(String[] args){
        Solution solution = new Solution();
        System.out.println(Arrays.toString(solution.findRelativeRanks(new int[]{5,4,3,2,1})));
    }

}
